<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/ptt','PermissionController@tt');

Route::get('/', 'SignController@index')->name('login');

Route::post('/', 'SignController@store')->name('login');

Route::get('/u', 'UploadController@index');

Route::group(['middleware' =>['auth']],function(){
    Route::get('/logout', 'SignController@logout')->name('logout');

    Route::get('/index', function () {
        return view('test');
    })->name('index');

    Route::get('/user','UserController@index')->name('user.index');
    Route::get('/user/{id}','UserController@edit')->name('user.edit')->where(['id' => '[0-9]+']);
    Route::post('/user/{id}','UserController@update')->name('user.edit');
    Route::get('/user/up-pwd/{id}','UserController@editPasswordById')->name('user.up-pwd');
    Route::put('/user/up-pwd/{id}','UserController@updatePasswordById')->name('user.up-pwd');
    Route::get('/register','UserController@create')->name('register');
    Route::post('/register','UserController@store')->name('register');

    Route::get('/profile','UserController@profile')->name('profile');
    Route::post('/profile/avatar','UserController@editAvatar')->name('profile.avatar');
    Route::post('/profile/password','UserController@updatePassword')->name('profile.password');

    Route::get('/role','RoleController@index')->name('role.index');
    Route::get('/role/create','RoleController@create')->name('role.create');
    Route::post('/role/create','RoleController@store')->name('role.create');
    Route::get('/role/{id}','RoleController@edit')->name('role.edit');
    Route::post('/role/{id}','RoleController@update')->name('role.edit');
    Route::delete('/role/{id}','RoleController@destroy')->name('role.destroy');

    Route::get('/permission','PermissionController@index')->name('permission.index');
    Route::get('/permission/create','PermissionController@create')->name('permission.create');
    Route::post('/permission/create','PermissionController@store')->name('permission.create');
    Route::get('/permission/{id}','PermissionController@edit')->name('permission.edit');
    Route::post('/permission/{id}','PermissionController@update')->name('permission.edit');
    Route::delete('/permission/{id}','PermissionController@destroy')->name('permission.destroy');
    Route::get('/permission/child/{pid?}','PermissionController@getChildPermissions')->name('permission.childs');


    //Route::namespace('Overtrue\LaravelUploader\Http\Controllers')->post('/files/upload','UploadController@upload')->name('file.upload');
});